package main

import (
	"fmt"
	"time"
)

func main() {
	getCurTime()
	time2str()
	getCurTimestamp()
	//intervalTask()
	countdownSyncTask()
}

func getCurTime() {
	curLocalTime := time.Now()

	utc := time.Now().UTC()

	fmt.Println(curLocalTime, utc)
}

func time2str() {
	localDateTimeStr := time.Now().Format("2006-01-02 15:04:05")
	fmt.Println(localDateTimeStr)
}

func getCurTimestamp() {
	timestamp := time.Now().Unix()
	fmt.Println(timestamp)
}

func intervalTask() {
	ticker := time.NewTicker(time.Second * 5)
	go func() {
		for c := range ticker.C {
			fmt.Printf("%v\n", c)
		}
	}()

	time.Sleep(time.Minute)
}

func countdownSyncTask() {
	time1 := time.NewTimer(time.Second * 5)
	<-time1.C

	fmt.Println("Hello, world")
}
